package com.java.exer_3;

import java.util.Calendar;
import java.util.GregorianCalendar;

public class TestCalendar_1 {

    public static void main(String[] args) {
        //输入当月日历
        //定义当前日历对象
        GregorianCalendar nowGc = new GregorianCalendar();
        //获取当前月份
        int month = nowGc.get(Calendar.MONTH);
        //设置日历对象从当月1日开始
        nowGc.set(Calendar.DAY_OF_MONTH, 1);
//        System.out.println(nowGc.getTime().toLocaleString());
        //补足1号之前的空白天
        for (int i = 0; i < nowGc.get(Calendar.DAY_OF_WEEK) - 1; i++) {
            System.out.print("\t");
        }
        while (nowGc.get(Calendar.MONTH) == month) {
            //获取日
            int day = nowGc.get(Calendar.DAY_OF_MONTH);
            //打印日
            System.out.print(day + "\t");
            //判断是否周六，如果是换行
            if (nowGc.get(Calendar.DAY_OF_WEEK) == 7) {
                System.out.println();
            }
            //累加日
            nowGc.add(Calendar.DAY_OF_MONTH, 1);
        }
    }
}
